import java.util.Scanner;

public class Test {
    class TreeNode{
        char val;
        TreeNode left;
        TreeNode right;

        public TreeNode(char val) {
            this.val = val;
        }
    }
    public static int i = 0;
    public  TreeNode create(String str){
        TreeNode root = null;
        if(str.charAt(i) != '#'){
            root = new TreeNode(str.charAt(i));
            i++;
            root.left = create(str);
            root.right = create(str);
        }else {
            i++;
        }
        return root;
    }

    public static void MiddleOrder(TreeNode root){
        if(root ==null ) return ;

        MiddleOrder(root.left);
        System.out.println(root.val+" ");
        MiddleOrder(root.right);

    }





    public static void main(String[] args) {
        Test test = new Test();

        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            TreeNode treeNode = test.create(str);
            MiddleOrder(treeNode);
        }
    }
}
